<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=" initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  <meta name = "format-detection" content = "telephone=no">
    <script src="../public/lobster/js/public.js"></script>
    <meta name = "format-detection" content = "telephone=no">
    <link rel="stylesheet" href="../public/lobster/css/public.css">
    <link rel="stylesheet" href="../public/lobster/icon/iconfont.css">
    <link rel="stylesheet" href="../public/lobster/css/regsiter.css">
    <script src="../public/lobster/js/lick.js"></script>
    <script src="../public/lobster/js/click.js"></script>
    <title>忘记密码</title>
</head>
<body>
<div class="start_logo" style="width:100%;">
    <img src="../public/lobster/images/login.png" alt="" style="width:100%;">
</div>
<!--主体-表单-->
<div id="start_reg_inp">
    <div class="st_fd_inp st_reg_tel">
        <span class="iconfont icon-shouji"></span>
        <input type="text"  name="mobile" id="mobile" class="st_reg_tel" placeholder="手机号" >
        <h4></h4>
    </div>
    <span id="phome"></span>
    <div class="st_fd_inp">
        <span class="iconfont icon-yanzhengma"></span>
        <input type="text" class="st_reg_code" name="code" id="code" placeholder="验证码">
        <h4></h4>
        <button id="reg_code" class="reg_code" onclick="code_res()">获取验证码</button>
    </div>
    <span id="token"></span>
    <div class="st_fd_inp">
        <span class="iconfont icon-mima2"></span>
        <input type="password" name="password" id="password" class="st_reg_ma" placeholder="请设置密码">
        <h4></h4>
    </div>
    <span id="pwd"></span>
    <div class="st_fd_inp">
        <span class="iconfont icon-gou2"></span>
        <input type="password" name="repeat_password" id="repeat_password" class="st_reg_mato" placeholder="请确认密码">
        <h4></h4>
    </div>
    <span id="msg"></span>
    <p>*密码为6位数字组成</p>
</div>
<!--主体-确认按钮-->
<div id="start_reg_btn">
    <input type="button" class="st_reg_btn"  value="确 认" onclick="findBack()">
</div>
</body>
<script src="../public/lobster/js/jq-2.1.0.js"></script>
<script src="../public/lobster/js/public.js"></script>
<script>
    $(function(){
        $("input").focus(function(){
            $("h4").html("");
        });
    })
    //提交验证
   /*  function success(){
        if(frmtel("#st_reg_tel")&&noempty('.st_reg_code')&&frmpwd('.st_reg_ma')&&againpwd(".st_reg_mato",'.st_reg_ma')){
            window.location.href="index.html";
        }
    } */
    
    
    //验证码发送一分钟倒计时
    var wait = 60;
    function countTime() {

        if (wait == 0) { 
        	$("#reg_code").attr("disabled",false);
        	$("#reg_code").text("获取验证码"); 
          	wait = 60; 
        } else { 
        	$("#reg_code").attr("disabled",true); 
        	$("#reg_code").text(wait+"秒后可再发送"); 
          wait--; 
          setTimeout(function() { 
        	  countTime();
          }, 
          1000) 
        } 
      }
    
    
    var hasSendCode = 0;  //0表示没有发送验证码 1表示发送了
	var phone = /^0?1[3|4|5|7|8][0-9]\d{8}$/;
	function code_res()
	{
		if(wait!=60){
    		return;
    	}
		
		if(!phone.test(document.getElementById('mobile').value))
		{
			//alert("手机格式不对");
			$("#phome").html("<font color='red' size='4px'>手机格式不对!</font>");
			return;
		}
		if(document.getElementById('mobile').value)
		{
			$.post('FPsendMsg',{loginname:document.getElementById('mobile').value},function(data){
				if(data.success)
				{
					//alert('验证码已经发送，请接收后填写。');
					countTime();//验证码发送倒计时
					$("#msg").html("<font color='red' size='4px'>验证码已经发送，请接收后填写。</font>");
					hasSendCode = 1;
				}else
				{
					//alert(data.msg);
					$("#msg").html("<font color='red' size='4px'>"+data.msg+"!</font>");
				}
			}, "json");
		}
		else
		{
			//alert("请填写手机号码");
			$("#phome").html("<font color='red' size='4px'>请填写手机号码!</font>");
		}
	}
	
	var reg = /^[0-9a-zA-Z]{6,99}$/;
	function findBack()
	{
		if(!document.getElementById('mobile').value)
		{
			//alert("请填写账号");
			$("#phome").html("<font color='red' size='4px'>请填写手机号码!</font>");
			return;
		}
		if(!phone.test(document.getElementById('mobile').value))
		{
			//alert("手机格式不对");
			$("#phome").html("<font color='red' size='4px'>手机格式不对!</font>");
			return;
		}
		if(!document.getElementById('code').value)
		{
			//alert("请填写验证码");
			$("#token").html("<font color='red' size='4px'>请填写验证码!</font>");
			return;
		}
		if(document.getElementById('code').value.length!=4)
		{
			//alert("验证码格式错误");
			$("#token").html("<font color='red' size='4px'>验证码格式错误!</font>");
			return;
		}
		/*
		if(hasSendCode==0)

		{
			//alert("您还没有发送过验证码");
			$("#token").html("<font color='red' size='4px'>您还没有发送过验证码!</font>");
			return;
		}
		*/
		if(document.getElementById('password').value.length<6)
		{
			//alert("密码必须大于6位");
			$("#pwd").html("<font color='red' size='4px'>新密码必须大于6位!</font>");
			return;
		}
		if(!reg.test(document.getElementById('password').value))
		{
			//alert("密码必须由数字或字母组成");
			$("#pwd").html("<font color='red' size='4px'>密码必须由数字或字母组成!</font>");
			return;
		}
		if(document.getElementById('password').value!=document.getElementById('repeat_password').value)
		{
			//alert("密码不一致");
			$("#msg").html("<font color='red' size='4px'>两次输入密码不一致!</font>");
			return;
		}
		$.post('FBCorrection',{loginname:document.getElementById('mobile').value,code:document.getElementById('code').value,pwd:document.getElementById('password').value,repwd:document.getElementById('repeat_password').value},function(data){
				if(data.success)
				{
					alert("密码修改成功，请重新登录");
					window.location.href="/index";
				}
				else
				{
					//alert(data.msg);
					$("#msg").html("<font color='red' size='4px'>"+data.msg+"!</font>");
				}
		}, "json");
		
	}
	
	$(document).on('focus','input',function(e){
    	$("#phome").html("");	
    	$("#token").html("");
    	$("#pwd").html("");
    	$("#msg").html("");
    });
</script>
</html>
